package com.gitee.feizns.explore.data_structure.tree.bs.easy;

/**
 * @author feizns
 * @since 2019/12/9
 */
public class MaxDepth {

    public static int maxDepth(TreeNode root) {
        return maxDepth(root, 0);
    }

    public static int maxDepth(TreeNode root, int depth) {
        return root == null
                ? depth
                : Math.max(maxDepth(root.left, depth + 1), maxDepth(root.right, depth + 1));
    }

}
